package design.observer.example;

/**
 * @author chengzhang
 * 2021/9/30 15:39
 */

import java.util.Vector;

/**
 * 被观察者
 */
abstract public class Subject {

    private Vector<Observer> obs = new Vector();

    public void addObserver(Observer obs){
        this.obs.add(obs);
    }

    public void delObserver(Observer obs){
        this.obs.remove(obs);
    }

    protected void notifyObserver(){
        for(Observer o: obs){
            o.update();
        }
    }

    public abstract void doSomething();


}
